package com.codeazur.as3abc.factories
{
	import com.codeazur.as3abc.data.bytecode.Opcodes;
	import com.codeazur.as3abc.data.bytecode.operations.*;
	
	public class OperationFactory
	{
		public function create(code:int):AbstractOperation
		{
			switch (code) {
				case Opcodes.Add:					return new BasicOperation(code);
				case Opcodes.AddDouble:				return new BasicOperation(code);
				case Opcodes.AddInt:				return new BasicOperation(code);
				case Opcodes.ApplyType:				return new IntOperation(code);
				case Opcodes.AsType:				return new MultinameOperation(code);
				case Opcodes.AsTypeLate:			return new BasicOperation(code);
				case Opcodes.BitAnd:				return new BasicOperation(code);
				case Opcodes.BitNot:				return new BasicOperation(code);
				case Opcodes.BitOr:					return new BasicOperation(code);
				case Opcodes.BitXor:				return new BasicOperation(code);
				case Opcodes.Breakpoint:			return new BasicOperation(code);
				case Opcodes.BreakpointLine:		return new BasicOperation(code);
				case Opcodes.Call:					return new IntOperation(code);
				case Opcodes.CallMethod:			return new MethodOperation(code);
				case Opcodes.CallProperty:			return new MultinameIntOperation(code);
				case Opcodes.CallPropLex:			return new MultinameIntOperation(code);
				case Opcodes.CallPropVoid:			return new MultinameIntOperation(code);
				case Opcodes.CallStatic:			return new MethodOperation(code);
				case Opcodes.CallSuper:				return new MultinameIntOperation(code);
				case Opcodes.CallSuperVoid:			return new MultinameIntOperation(code);
				case Opcodes.CheckFilter:			return new BasicOperation(code);
				case Opcodes.Coerce:				return new MultinameOperation(code);
				case Opcodes.CoerceAny:				return new BasicOperation(code);
				case Opcodes.CoerceBoolean:			return new BasicOperation(code);
				case Opcodes.CoerceDouble:			return new BasicOperation(code);
				case Opcodes.CoerceInt:				return new BasicOperation(code);
				case Opcodes.CoerceObject:			return new BasicOperation(code);
				case Opcodes.CoerceString:			return new BasicOperation(code);
				case Opcodes.CoerceUInt:			return new BasicOperation(code);
				case Opcodes.Concat:				return new BasicOperation(code);
				case Opcodes.Construct:				return new IntOperation(code);
				case Opcodes.ConstructProp:			return new MultinameIntOperation(code);
				case Opcodes.ConstructSuper:		return new IntOperation(code);
				case Opcodes.ConvertBoolean:		return new BasicOperation(code);
				case Opcodes.ConvertDouble:			return new BasicOperation(code);
				case Opcodes.ConvertInt:			return new BasicOperation(code);
				case Opcodes.ConvertObject:			return new BasicOperation(code);
				case Opcodes.ConvertString:			return new BasicOperation(code);
				case Opcodes.ConvertUInt:			return new BasicOperation(code);
				case Opcodes.Debug:					return new IntStringIntIntOperation(code);
				case Opcodes.DebugFile:				return new StringOperation(code);
				case Opcodes.DebugLine:				return new IntOperation(code);
				case Opcodes.DecLocal:				return new IntOperation(code);
				case Opcodes.DecLocalInt:			return new IntOperation(code);
				case Opcodes.Decrement:				return new BasicOperation(code);
				case Opcodes.DecrementInt:			return new BasicOperation(code);
				case Opcodes.DefaultXmlNamespace:	return new StringOperation(code);
				case Opcodes.DefaultXmlNamespaceL:	return new BasicOperation(code);
				case Opcodes.DeleteProperty:		return new MultinameOperation(code);
				case Opcodes.DeletePropertyLate:	return new BasicOperation(code);
				case Opcodes.Divide:				return new BasicOperation(code);
				case Opcodes.Dup:					return new BasicOperation(code);
				case Opcodes.Equals:				return new BasicOperation(code);
				case Opcodes.EscXmlAttr:			return new BasicOperation(code);
				case Opcodes.EscXmlElem:			return new BasicOperation(code);
				case Opcodes.FindProperty:			return new MultinameOperation(code);
				case Opcodes.FindPropStrict:		return new MultinameOperation(code);
				case Opcodes.GetByte:				return new BasicOperation(code);
				case Opcodes.GetDescendants:		return new MultinameOperation(code);
				case Opcodes.GetDouble:				return new BasicOperation(code);
				case Opcodes.GetFloat:				return new BasicOperation(code);
				case Opcodes.GetGlobalScope:		return new BasicOperation(code);
				case Opcodes.GetGlobalSlot:			return new IntOperation(code);
				case Opcodes.GetInt:				return new BasicOperation(code);
				case Opcodes.GetLex:				return new MultinameOperation(code);
				case Opcodes.GetLocal:				return new IntOperation(code);
				case Opcodes.GetLocal0:				return new BasicOperation(code);
				case Opcodes.GetLocal1:				return new BasicOperation(code);
				case Opcodes.GetLocal2:				return new BasicOperation(code);
				case Opcodes.GetLocal3:				return new BasicOperation(code);
				case Opcodes.GetProperty:			return new MultinameOperation(code);
				case Opcodes.GetPropertyLate:		return new BasicOperation(code);
				case Opcodes.GetScopeObject:		return new IntOperation(code);
				case Opcodes.GetShort:				return new BasicOperation(code);
				case Opcodes.GetSlot:				return new IntOperation(code);
				case Opcodes.GetSuper:				return new MultinameOperation(code);
				case Opcodes.GreaterEquals:			return new BasicOperation(code);
				case Opcodes.GreaterThan:			return new BasicOperation(code);
				case Opcodes.HasNext:				return new BasicOperation(code);
				case Opcodes.HasNext2:				return new IntIntOperation(code);
				case Opcodes.IfEqual:				return new ConditionalJumpOperation(code);
				case Opcodes.IfFalse:				return new ConditionalJumpOperation(code);
				case Opcodes.IfGreaterEqual:		return new ConditionalJumpOperation(code);
				case Opcodes.IfGreaterThan:			return new ConditionalJumpOperation(code);
				case Opcodes.IfLessEqual:			return new ConditionalJumpOperation(code);
				case Opcodes.IfLessThan:			return new ConditionalJumpOperation(code);
				case Opcodes.IfNotEqual:			return new ConditionalJumpOperation(code);
				case Opcodes.IfNotGreaterEqual:		return new ConditionalJumpOperation(code);
				case Opcodes.IfNotGreaterThan:		return new ConditionalJumpOperation(code);
				case Opcodes.IfNotLessEqual:		return new ConditionalJumpOperation(code);
				case Opcodes.IfNotLessThan:			return new ConditionalJumpOperation(code);
				case Opcodes.IfStrictEqual:			return new ConditionalJumpOperation(code);
				case Opcodes.IfStrictNotEqual:		return new ConditionalJumpOperation(code);
				case Opcodes.IfTrue:				return new ConditionalJumpOperation(code);
				case Opcodes.In:					return new BasicOperation(code);
				case Opcodes.IncLocal:				return new IntOperation(code);
				case Opcodes.IncLocalInt:			return new IntOperation(code);
				case Opcodes.Increment:				return new BasicOperation(code);
				case Opcodes.IncrementInt:			return new BasicOperation(code);
				case Opcodes.InitProperty:			return new MultinameOperation(code);
				case Opcodes.InstanceOf:			return new BasicOperation(code);
				case Opcodes.IsType:				return new MultinameOperation(code);
				case Opcodes.IsTypeLate:			return new BasicOperation(code);
				case Opcodes.Jump:					return new JumpOperation(code);
				case Opcodes.Kill:					return new IntOperation(code);
				case Opcodes.Label:					return new LabelOperation(code);
				case Opcodes.LessEquals:			return new BasicOperation(code);
				case Opcodes.LessThan:				return new BasicOperation(code);
				case Opcodes.LookupSwitch:			return new LookupSwitchOperation(code);
				case Opcodes.Modulo:				return new BasicOperation(code);
				case Opcodes.Multiply:				return new BasicOperation(code);
				case Opcodes.MultiplyInt:			return new BasicOperation(code);
				case Opcodes.Negate:				return new BasicOperation(code);
				case Opcodes.NegateInt:				return new BasicOperation(code);
				case Opcodes.NewActivation:			return new BasicOperation(code);
				case Opcodes.NewArray:				return new IntOperation(code);
				case Opcodes.NewCatch:				return new NewCatchOperation(code);
				case Opcodes.NewClass:				return new NewClassOperation(code);
				case Opcodes.NewFunction:			return new NewFunctionOperation(code);
				case Opcodes.NewObject:				return new IntOperation(code);
				case Opcodes.NextName:				return new BasicOperation(code);
				case Opcodes.NextValue:				return new BasicOperation(code);
				case Opcodes.Not:					return new BasicOperation(code);
				case Opcodes.Nop:					return new BasicOperation(code);
				case Opcodes.Pop:					return new BasicOperation(code);
				case Opcodes.PopScope:				return new BasicOperation(code);
				case Opcodes.PushByte:				return new IntOperation(code);
				case Opcodes.PushDouble:			return new NumberOperation(code);
				case Opcodes.PushFalse:				return new BasicOperation(code);
				case Opcodes.PushInt:				return new IntOperation(code);
				case Opcodes.PushNamespace:			return new NamespaceOperation(code);
				case Opcodes.PushNaN:				return new BasicOperation(code);
				case Opcodes.PushNull:				return new BasicOperation(code);
				case Opcodes.PushScope:				return new BasicOperation(code);
				case Opcodes.PushShort:				return new IntOperation(code);
				case Opcodes.PushString:			return new StringOperation(code);
				case Opcodes.PushTrue:				return new BasicOperation(code);
				case Opcodes.PushUInt:				return new UIntOperation(code);
				case Opcodes.PushUndefined:			return new BasicOperation(code);
				case Opcodes.PushWith:				return new BasicOperation(code);
				case Opcodes.ReturnValue:			return new BasicOperation(code);
				case Opcodes.ReturnVoid:			return new BasicOperation(code);
				case Opcodes.SetByte:				return new BasicOperation(code);
				case Opcodes.SetDouble:				return new BasicOperation(code);
				case Opcodes.SetFloat:				return new BasicOperation(code);
				case Opcodes.SetGlobalSlot:			return new IntOperation(code);
				case Opcodes.SetInt:				return new BasicOperation(code);
				case Opcodes.SetLocal:				return new IntOperation(code);
				case Opcodes.SetLocal0:				return new BasicOperation(code);
				case Opcodes.SetLocal1:				return new BasicOperation(code);
				case Opcodes.SetLocal2:				return new BasicOperation(code);
				case Opcodes.SetLocal3:				return new BasicOperation(code);
				case Opcodes.SetProperty:			return new MultinameOperation(code);
				case Opcodes.SetPropertyLate:		return new BasicOperation(code);
				case Opcodes.SetShort:				return new BasicOperation(code);
				case Opcodes.SetSlot:				return new IntOperation(code);
				case Opcodes.SetSuper:				return new MultinameOperation(code);
				case Opcodes.ShiftLeft:				return new BasicOperation(code);
				case Opcodes.ShiftRight:			return new BasicOperation(code);
				case Opcodes.ShiftRightUnsigned:	return new BasicOperation(code);
				case Opcodes.Sign1:					return new BasicOperation(code);
				case Opcodes.Sign16:				return new BasicOperation(code);
				case Opcodes.Sign8:					return new BasicOperation(code);
				case Opcodes.StrictEquals:			return new BasicOperation(code);
				case Opcodes.Subtract:				return new BasicOperation(code);
				case Opcodes.SubtractInt:			return new BasicOperation(code);
				case Opcodes.Swap:					return new BasicOperation(code);
				case Opcodes.Throw:					return new BasicOperation(code);
				case Opcodes.TypeOf:				return new BasicOperation(code);

				default:							
					trace("unknown: " + code.toString(16));
					return null;
			}
		}

	}
}